import config from '../../config'
	
export default {
  namespaced: true,
  state: {
    token: uni.getStorageSync('token') || '', 
	userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'), 
  },
  mutations: {
    setToken(state, token) {
		try{
			uni.setStorageSync('token', token)
		}catch(e){
			//TODO handle the exception
		}
		state.token = token
    },
	clearToken(state){
		try{
			uni.removeStorageSync('token')
		}catch(e){
			console.log('error')
		}
		state.token = null
	},
	setUserInfo(state, data) {
		try{
			uni.setStorageSync('userInfo', JSON.stringify(data))
		}catch(e){
			console.log('用户数据错误')
		}
		state.userInfo = data;
	}
  },
  actions: {
  }
}
